+2005-11-09 Tor Lillqvist <tml@novell.com>
+
+ * gdk/win32/gdkwindow-win32.c: Remove unnecessary includes.
+
+ (_gdk_win32_get_adjusted_client_rect): Remove this two-line
+ function which was used only in one place.
+
+ (get_outer_rect): Use _gdk_win32_adjust_client_rect().
+
+ (gdk_window_set_geometry_hints): If we have identical minimum and
+ maximum size hints, remove the resize and maximize
+ decorations/functions. (#104514)
+
+ If we have a maximum size hint, remove the maximize
+ decoration/function but ensure the resize decoration/function is
+ available. Otherwise ensure both resize and maximize
+ decorations/functions are there.
+
+ (set_or_clear_style_bits): Factored out common code from
+ gdk_window_set_decorations() and gdk_window_set_functions().
+
+ Hack the window style setting once more: Only touch the window
+ style bits corresponding to the GdkWMDecoration or GdkWMFunction
+ parameter bitmasks. Hopefully this finally is the correct thing to
+ do. We used to clear all other bits than those that were being
+ set, or set all other bits than those that were being cleared.
+
+ Take into account that adding or removing decorations leaves the
+ window's outer size unchanged, i.e., the client area's size and
+ position change. This is apparently not what we want, so change
+ also the window's (outer) position and size appropriately so that
+ the client area's position and size stay constant.
+
+ gtk-demo's color selector dialog is now non-resizable like on X11
+ (I tested with metacity in GNOME). Torn off menus are shrinkable
+ vertically but have a maximum size, and are not maximizable or
+ minimizable, like on X11.
+
+ (gdk_window_set_decorations, gdk_window_set_functions): Let
+ set_or_clear_decorations() do most of the job.
+
+ * gdk/win32/gdkprivate-win32.h: Remove declaration of
+ _gdk_win32_get_adjusted_client_rect().
+
2005-11-09 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkwindow-win32.h (struct _GdkWindowImplWin32)
+2005-11-09 Tor Lillqvist <tml@novell.com>
+
+ * gdk/win32/gdkwindow-win32.c: Remove unnecessary includes.
+
+ (_gdk_win32_get_adjusted_client_rect): Remove this two-line
+ function which was used only in one place.
+
+ (get_outer_rect): Use _gdk_win32_adjust_client_rect().
+
+ (gdk_window_set_geometry_hints): If we have identical minimum and
+ maximum size hints, remove the resize and maximize
+ decorations/functions. (#104514)
+
+ If we have a maximum size hint, remove the maximize
+ decoration/function but ensure the resize decoration/function is
+ available. Otherwise ensure both resize and maximize
+ decorations/functions are there.
+
+ (set_or_clear_style_bits): Factored out common code from
+ gdk_window_set_decorations() and gdk_window_set_functions().
+
+ Hack the window style setting once more: Only touch the window
+ style bits corresponding to the GdkWMDecoration or GdkWMFunction
+ parameter bitmasks. Hopefully this finally is the correct thing to
+ do. We used to clear all other bits than those that were being
+ set, or set all other bits than those that were being cleared.
+
+ Take into account that adding or removing decorations leaves the
+ window's outer size unchanged, i.e., the client area's size and
+ position change. This is apparently not what we want, so change
+ also the window's (outer) position and size appropriately so that
+ the client area's position and size stay constant.
+
+ gtk-demo's color selector dialog is now non-resizable like on X11
+ (I tested with metacity in GNOME). Torn off menus are shrinkable
+ vertically but have a maximum size, and are not maximizable or
+ minimizable, like on X11.
+
+ (gdk_window_set_decorations, gdk_window_set_functions): Let
+ set_or_clear_decorations() do most of the job.
+
+ * gdk/win32/gdkprivate-win32.h: Remove declaration of
+ _gdk_win32_get_adjusted_client_rect().
+
2005-11-09 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkwindow-win32.h (struct _GdkWindowImplWin32)
#include <config.h>
#include <stdlib.h>
-#include "gdk.h" /* gdk_rectangle_intersect */
-#include "gdkevents.h"
-#include "gdkpixmap.h"
-#include "gdkwindow.h"
-#include "gdkdisplay.h"
+#include "gdk.h"
#include "gdkprivate-win32.h"
#include "gdkinput-win32.h"
API_CALL (AdjustWindowRectEx, (rect, style, FALSE, exstyle));
}
-void
-_gdk_win32_get_adjusted_client_rect (GdkWindow *window,
- RECT *rect)
-{
- GetClientRect (GDK_WINDOW_HWND (window), rect);
- _gdk_win32_adjust_client_rect (window, rect);
-}
-
static GdkColormap*
gdk_window_impl_win32_get_colormap (GdkDrawable *drawable)
{
gint height,
RECT *rect)
{
- LONG style, exstyle;
-
- style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
- exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
-
rect->left = rect->top = 0;
rect->right = width;
rect->bottom = height;
- API_CALL (AdjustWindowRectEx, (rect, style, FALSE, exstyle));
+ _gdk_win32_adjust_client_rect (window, rect);
}
static void
else
{
RECT outer_rect;
+
get_outer_rect (window, width, height, &outer_rect);
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,0,0,%ld,%ld,"
geometry->max_width, geometry->max_height));
}
+ if ((geom_mask & GDK_HINT_MIN_SIZE) &&
+ (geom_mask & GDK_HINT_MAX_SIZE) &&
+ geometry->min_width == geometry->max_width &&
+ geometry->min_height == geometry->max_height)
+ gdk_window_set_decorations (window,
+ GDK_DECOR_ALL |
+ GDK_DECOR_RESIZEH |
+ GDK_DECOR_MAXIMIZE);
+ else if (geom_mask & GDK_HINT_MAX_SIZE)
+ {
+ gdk_window_set_decorations (window,
+ GDK_DECOR_ALL |
+ GDK_DECOR_MAXIMIZE);
+ gdk_window_set_decorations (window,
+ GDK_DECOR_RESIZEH);
+ }
+ else
+ gdk_window_set_decorations (window,
+ GDK_DECOR_RESIZEH |
+ GDK_DECOR_MAXIMIZE);
+
if (geom_mask & GDK_HINT_BASE_SIZE)
{
GDK_NOTE (MISC, g_print ("... BASE_SIZE: %dx%d\n",
GDK_WINDOW_HWND (window),
GDK_WINDOW_HWND (mask)));
- _gdk_win32_get_adjusted_client_rect (window, &rect);
+ GetClientRect (GDK_WINDOW_HWND (window), &rect);
+ _gdk_win32_adjust_client_rect (window, &rect);
OffsetRgn (hrgn, -rect.left, -rect.top);
OffsetRgn (hrgn, x, y);
g_warning ("gdk_window_set_group not implemented");
}
+static void
+set_or_clear_style_bits (GdkWindow *window,
+ gboolean clear_bits,
+ int bits)
+{
+ LONG style, exstyle;
+ RECT rect, before, after;
+
+ style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
+
+ GetClientRect (GDK_WINDOW_HWND (window), &before);
+ after = before;
+ AdjustWindowRectEx (&before, style, FALSE, exstyle);
+
+ if (clear_bits)
+ style &= ~bits;
+ else
+ style |= bits;
+
+ SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
+
+ AdjustWindowRectEx (&after, style, FALSE, exstyle);
+
+ GetWindowRect (GDK_WINDOW_HWND (window), &rect);
+ rect.left += after.left - before.left;
+ rect.top += after.top - before.top;
+ rect.right += after.right - before.right;
+ rect.bottom += after.bottom - before.bottom;
+
+ SetWindowPos (GDK_WINDOW_HWND (window), NULL,
+ rect.left, rect.top,
+ rect.right - rect.left, rect.bottom - rect.top,
+ SWP_FRAMECHANGED | SWP_NOACTIVATE |
+ SWP_NOREPOSITION | SWP_NOZORDER);
+}
+
void
gdk_window_set_decorations (GdkWindow *window,
GdkWMDecoration decorations)
{
- LONG style, bits;
- const LONG settable_bits = WS_BORDER|WS_THICKFRAME|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
+ int bits;
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("gdk_window_set_decorations: %p: %s%s%s%s%s%s%s\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_set_decorations: %p: %s %s%s%s%s%s%s\n",
GDK_WINDOW_HWND (window),
- (decorations & GDK_DECOR_ALL ? "ALL " : ""),
+ (decorations & GDK_DECOR_ALL ? "clearing" : "setting"),
(decorations & GDK_DECOR_BORDER ? "BORDER " : ""),
(decorations & GDK_DECOR_RESIZEH ? "RESIZEH " : ""),
(decorations & GDK_DECOR_TITLE ? "TITLE " : ""),
(decorations & GDK_DECOR_MINIMIZE ? "MINIMIZE " : ""),
(decorations & GDK_DECOR_MAXIMIZE ? "MAXIMIZE " : "")));
- style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
-
bits = 0;
if (decorations & GDK_DECOR_BORDER)
if (decorations & GDK_DECOR_MAXIMIZE)
bits |= WS_MAXIMIZEBOX;
- if (decorations & GDK_DECOR_ALL)
- style |= settable_bits, style &= ~bits;
- else
- style &= ~settable_bits, style |= bits;
-
- SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
- SetWindowPos (GDK_WINDOW_HWND (window), NULL,
- 0, 0, 0, 0,
- SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
- SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+ set_or_clear_style_bits (window, (decorations & GDK_DECOR_ALL), bits);
}
gboolean
gdk_window_set_functions (GdkWindow *window,
GdkWMFunction functions)
{
- LONG style, bits;
- const LONG settable_bits = (WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU);
+ int bits;
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("gdk_window_set_functions: %p: %s%s%s%s%s%s\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_set_functions: %p: %s %s%s%s%s%s\n",
GDK_WINDOW_HWND (window),
- (functions & GDK_FUNC_ALL ? "ALL " : ""),
+ (functions & GDK_FUNC_ALL ? "clearing" : "setting"),
(functions & GDK_FUNC_RESIZE ? "RESIZE " : ""),
(functions & GDK_FUNC_MOVE ? "MOVE " : ""),
(functions & GDK_FUNC_MINIMIZE ? "MINIMIZE " : ""),
(functions & GDK_FUNC_MAXIMIZE ? "MAXIMIZE " : ""),
(functions & GDK_FUNC_CLOSE ? "CLOSE " : "")));
- style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
-
bits = 0;
if (functions & GDK_FUNC_RESIZE)
if (functions & GDK_FUNC_CLOSE)
bits |= WS_SYSMENU;
- if (functions & GDK_FUNC_ALL)
- style |= settable_bits, style &= ~bits;
- else
- style &= ~settable_bits, style |= bits;
-
- SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
- SetWindowPos (GDK_WINDOW_HWND (window), NULL,
- 0, 0, 0, 0,
- SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
- SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+ set_or_clear_style_bits (window, (functions & GDK_FUNC_ALL), bits);
}
static void